using System.ComponentModel.DataAnnotations;

namespace DeathReportManagement.Models;

public class DeathReport
{
    public int Id { get; set; }
    
    [Required]
    [StringLength(50)]
    public string ReportNo { get; set; } = string.Empty;
    
    [StringLength(50)]
    public string? OutpatientNo { get; set; }
    
    [StringLength(50)]
    public string? InpatientNo { get; set; }
    
    public int? HospitalizationCount { get; set; }
    
    [Required]
    [StringLength(100)]
    public string DeceasedName { get; set; } = string.Empty;
    
    public bool IsAnonymous { get; set; } = false;
    
    [Required]
    [StringLength(10)]
    public string Gender { get; set; } = string.Empty;
    
    [Required]
    [StringLength(50)]
    public string Ethnicity { get; set; } = string.Empty;
    
    [StringLength(50)]
    public string CountryOrRegion { get; set; } = "中国";
    
    [Required]
    [StringLength(50)]
    public string IdType { get; set; } = string.Empty;
    
    [Required]
    [StringLength(50)]
    public string IdNumber { get; set; } = string.Empty;
    
    [Required]
    public DateOnly BirthDate { get; set; }
    
    [Required]
    public int Age { get; set; }
    
    [Required]
    [StringLength(10)]
    public string AgeUnit { get; set; } = string.Empty;
    
    [Required]
    [StringLength(20)]
    public string MaritalStatus { get; set; } = string.Empty;
    
    [Required]
    [StringLength(50)]
    public string Education { get; set; } = string.Empty;
    
    [Required]
    [StringLength(50)]
    public string PersonalIdentity { get; set; } = string.Empty;
    
    [Required]
    public DateTime DeathDateTime { get; set; }
    
    [Required]
    [StringLength(100)]
    public string DeathLocation { get; set; } = string.Empty;
    
    public bool IsPregnant { get; set; } = false;
    
    [Required]
    [StringLength(200)]
    public string WorkUnit { get; set; } = string.Empty;
    
    [StringLength(20)]
    public string HouseholdAddressType { get; set; } = "本县区";
    
    [StringLength(500)]
    public string? HouseholdAddress { get; set; }
    
    [StringLength(50)]
    public string? HouseholdAddressCode { get; set; }
    
    [Required]
    [StringLength(500)]
    public string HouseholdDetailAddress { get; set; } = string.Empty;
    
    [Required]
    [StringLength(20)]
    public string ResidenceAddressType { get; set; } = string.Empty;
    
    [Required]
    [StringLength(500)]
    public string ResidenceAddress { get; set; } = string.Empty;
    
    [Required]
    [StringLength(500)]
    public string ResidenceDetailAddress { get; set; } = string.Empty;
    
    [Required]
    [StringLength(100)]
    public string ContactName { get; set; } = string.Empty;
    
    [Required]
    [StringLength(50)]
    public string ContactPhone { get; set; } = string.Empty;
    
    [StringLength(50)]
    public string ContactIdType { get; set; } = "身份证";
    
    // 32. 家属住址或工作单位
    [Required]
    [StringLength(200)]
    public string FamilyAddressOrWorkUnit { get; set; } = string.Empty;
    
    // 死因链A-D字段
    // 33. 直接导致死亡的疾病A
    [Required]
    [StringLength(200)]
    public string DeathCauseA { get; set; } = string.Empty;
    
    // 34. 疾病A的ICD10编码
    [StringLength(10)]
    public string? DeathCauseAIcd10 { get; set; }
    
    // 35. A疾病发病至死亡的时间间隔
    [Range(0, 999.9)]
    public decimal? DeathCauseAInterval { get; set; }
    
    // 36. 间隔时间单位A
    [StringLength(10)]
    public string? DeathCauseAIntervalUnit { get; set; }
    
    // 37. 直接导致死亡的疾病B
    [StringLength(200)]
    public string? DeathCauseB { get; set; }
    
    // 38. 疾病B的ICD10编码
    [StringLength(10)]
    public string? DeathCauseBIcd10 { get; set; }
    
    // 39. B疾病发病至死亡的时间间隔
    [Range(0, 999.9)]
    public decimal? DeathCauseBInterval { get; set; }
    
    // 40. 间隔时间单位B
    [StringLength(10)]
    public string? DeathCauseBIntervalUnit { get; set; }
    
    // 41. 直接导致死亡的疾病C
    [StringLength(200)]
    public string? DeathCauseC { get; set; }
    
    // 42. 疾病C的ICD10编码
    [StringLength(10)]
    public string? DeathCauseCIcd10 { get; set; }
    
    // 43. C疾病发病至死亡的时间间隔
    [Range(0, 999.9)]
    public decimal? DeathCauseCInterval { get; set; }
    
    // 44. 间隔时间单位C
    [StringLength(10)]
    public string? DeathCauseCIntervalUnit { get; set; }
    
    // 45. 直接导致死亡的疾病D
    [StringLength(200)]
    public string? DeathCauseD { get; set; }
    
    // 46. 疾病D的ICD10编码
    [StringLength(10)]
    public string? DeathCauseDIcd10 { get; set; }
    
    // 47. D疾病发病至死亡的时间间隔
    [Range(0, 999.9)]
    public decimal? DeathCauseDInterval { get; set; }
    
    // 48. 间隔时间单位D
    [StringLength(10)]
    public string? DeathCauseDIntervalUnit { get; set; }
    
    // 49. 其他疾病原因
    [StringLength(200)]
    public string? OtherCause { get; set; }
    
    // 50. 其他病因ICD10编码
    [StringLength(10)]
    public string? OtherCauseIcd10 { get; set; }
    
    // 51. 根本死亡原因描述
    [StringLength(200)]
    public string? UnderlyingCause { get; set; }
    
    // 52. 根本死亡原因ICD10编码
    [StringLength(10)]
    public string? UnderlyingCauseIcd10 { get; set; }
    
    // 53. 最高诊断单位
    [StringLength(20)]
    public string? HighestDiagnosisUnit { get; set; }
    
    // 54. 最高诊断依据
    [StringLength(20)]
    public string? HighestDiagnosisBasis { get; set; }
    
    // 55. 填卡医生
    [Required]
    [StringLength(50)]
    public string FillingDoctor { get; set; } = string.Empty;
    
    // 56. 医生填卡日期
    public DateTime FillingDate { get; set; } = DateTime.Now;
    
    // 57. 审核人
    [StringLength(50)]
    public string? AuditorName { get; set; }
    
    // 58. 民警签名
    [StringLength(50)]
    public string? PoliceSignature { get; set; }
    
    // 59. 备注
    [StringLength(40)]
    public string? Remarks { get; set; }
    
    // 60. 死者生前病史及症状体征
    [StringLength(800)]
    public string? MedicalHistoryAndSymptoms { get; set; }
    
    // 61. 被调查者姓名
    [StringLength(20)]
    public string? IntervieweeName { get; set; }
    
    // 62. 与死者关系
    [StringLength(10)]
    public string? RelationshipToDeceased { get; set; }
    
    // 63. 联系地址或工作单位
    [StringLength(100)]
    public string? IntervieweeAddress { get; set; }
    
    // 64. 被调查者电话号码
    [StringLength(18)]
    public string? IntervieweePhone { get; set; }
    
    // 65. 死因推断
    [StringLength(60)]
    public string? CauseInference { get; set; }
    
    // 66. 调查者签名
    [StringLength(20)]
    public string? InvestigatorSignature { get; set; }
    
    // 67. 调查日期
    public DateTime? InvestigationDate { get; set; }
    
    // 68. 审核日期
    public DateTime? AuditDate { get; set; }
    
    // 69. 错误内容
    [StringLength(300)]
    public string? ErrorContent { get; set; }
    
    public AuditStatus AuditStatus { get; set; } = AuditStatus.Pending;
    
    public ReportStatus ReportStatus { get; set; } = ReportStatus.NotReported;
    
    [Required]
    public int CreateBy { get; set; }
    
    public DateTime CreateTime { get; set; } = DateTime.Now;
    
    public int? UpdateBy { get; set; }
    
    public DateTime? UpdateTime { get; set; }
    
    public int? AuditBy { get; set; }
    
    public DateTime? AuditTime { get; set; }
    
    public User Creator { get; set; } = null!;
    public User? Updater { get; set; }
    public User? Auditor { get; set; }
    public ICollection<OperationLog> OperationLogs { get; set; } = new List<OperationLog>();
}

public enum AuditStatus
{
    Pending = 0,
    Approved = 1
}

public enum ReportStatus
{
    NotReported = 0,
    SubReported = 1,
    MainReported = 2
}